//
//  MeHeadView.m
//  SinaWebo
//
//  Created by wwj on 16/1/19.
//  Copyright © 2016年 亦心. All rights reserved.
//

#import "MeHeadView.h"
#import "UserPerfenceUtil.h"
#import "UIImageView+WebCache.h"

@interface MeHeadView ()
@property (weak, nonatomic) IBOutlet UIImageView *imgView;
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *desc;
@property (weak, nonatomic) IBOutlet UILabel *wbNumber;
@property (weak, nonatomic) IBOutlet UILabel *viewNumber;
@property (weak, nonatomic) IBOutlet UILabel *peopleNumber;
@end

@implementation MeHeadView

-(void)awakeFromNib{
    _imgView.layer.cornerRadius = _imgView.frame.size.width * 0.5;
    _imgView.userInteractionEnabled = YES;
    
    [_imgView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickImg)]];
    [self setData];
    
}

- (void)onClickImg{
    if ([_delegate respondsToSelector:@selector(onClickHeadImg:)]) {
        [_delegate onClickHeadImg:self];
    }
}

- (IBAction)onClickVip:(UIButton *)sender {
    if ([_delegate respondsToSelector:@selector(onClickVip:)]) {
        [_delegate onClickVip:self];
    }
}


-(void)setData{
    Account *account = [UserPerfenceUtil account];
    [_imgView sd_setImageWithURL :[NSURL URLWithString:account.avatar_hd] placeholderImage:nil];
    _name.text = account.name;
    _wbNumber.text = account.statuses_count;
    _viewNumber.text = account.friends_count;
    _peopleNumber.text = account.followers_count;
    if ([account.desc isEqualToString:@""] || account.desc == nil) {
        _desc.text = @"简介:暂无简介";
    }else{
        _desc.text = account.desc;
    }
}

@end
